<template>
  <view class="page-container">
    <!-- 顶部轮播图 -->
    <view class="swiper-section">
      <u-swiper
        :list="list3"
        :height="200"
        circular
        indicator
        indicatorMode="line"
        :borderRadius="12"
        :interval="4000"
        :imgMode="'aspectFill'"
        bgColor="#f5f6fa"
      />
    </view>

    <!-- 服务导航网格 -->
    <view class="grid-container">
      <!-- 门票购买 -->
      <view class="grid-item ticket" @tap="handleNavigate('ticket')">
        <view class="item-content">
          <text class="material-icons control-icon">local_activity</text>
          <view class="text-container">
            <text class="title">门票购买</text>
            <text class="subtitle">Ticket Purchase</text>
          </view>
          <text class="action">购票</text>
        </view>
      </view>

      <!-- 今日节目单 -->
      <view class="grid-item programme" @tap="handleNavigate('programme')">
        <view class="item-content">
          <text class="material-icons control-icon">event_note</text>
          <view class="text-container">
            <text class="title">活动介绍</text>
            <text class="subtitle">Today's Events</text>
          </view>
          <text class="action">查看</text>
        </view>
      </view>

      <!-- 文创商城 -->
      <view class="grid-item shop" @tap="handleNavigate('service')">
        <view class="item-content">
          <text class="material-icons control-icon">shopping_cart</text>
          <view class="text-container">
            <text class="title">文创商品</text>
            <text class="subtitle">Cultural Products</text>
          </view>
        </view>
      </view>
      <!-- 电影小镇喜见客栈 -->
      <view class="grid-item hotel-movie" @tap="handleNavigate('movie-hotel')">
        <view class="item-content">
          <text class="material-icons control-icon">hotel</text>
          <view class="text-container">
            <text class="title">电影小镇酒店</text>
            <text class="subtitle">Movie Town Hotel</text>
          </view>
          <text class="action">预订</text>
        </view>
      </view>



      <!-- 景+酒套餐 -->
      <view class="grid-item hotel" @tap="handleNavigate('scenic-hotel')">
        <view class="item-content">
          <text class="material-icons control-icon">local_hotel</text>
          <view class="text-container">
            <text class="title">酒店住宿</text>
            <text class="subtitle">Hotel & Scenic Package</text>
          </view>
          <text class="book-now">立即预订</text>
        </view>
      </view>

      <!-- 餐饮美食 -->
      <view class="grid-item movie" @tap="handleNavigate('food')">
        <view class="item-content">
          <text class="material-icons control-icon">restaurant_menu</text>
          <view class="text-container">
            <text class="title">餐饮美食</text>
            <text class="subtitle">Food & Beverages</text>
          </view>
          <text class="action">点餐</text>
        </view>
      </view>

      <!-- 电子导览 -->
      <view class="grid-item map" @tap="handleNavigate('guide')">
        <view class="item-content">
          <text class="material-icons control-icon">map</text>
          <view class="text-container">
            <text class="title">电子导览</text>
            <text class="subtitle">Digital Guide</text>
          </view>
          <text class="action">导览</text>
        </view>
      </view>
      <!-- 博物馆 -->
      <view class="grid-item hotel-movie" @tap="handleNavigate('movie-hotel')">
        <view class="item-content">
          <text class="material-icons control-icon">bed</text>
          <view class="text-container">
            <text class="title">博物馆</text>
            <text class="subtitle">Movie Town Hotel</text>
          </view>
          <text class="action">预订</text>
        </view>
      </view>
      <!-- 客服电话 -->
      <view class="grid-item service" @tap="handleCall">
        <view class="item-content">
          <text class="material-icons control-icon">headset_mic</text>
          <view class="text-container">
            <text class="title">客服电话</text>
            <text class="subtitle">Customer Service</text>
          </view>
          <text class="phone">400-000-1992</text>
        </view>
      </view>


      <!-- 停车收费 -->
      <view class="grid-item hotel-movie" @tap="handleNavigate('movie-hotel')">
        <view class="item-content">
          <text class="material-icons control-icon">bed</text>
          <view class="text-container">
            <text class="title">停车收费</text>
            <text class="subtitle">Movie Town Hotel</text>
          </view>
          <text class="action">预订</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
const list3 = ref([
  'https://szhy.artcollegehb.cn/school/file/school/fj/20240106/14130edc8a054741832d92335f847e6a4cc014a87f65b75ba38162913a3808f.png',
  'https://szhy.artcollegehb.cn/school/file/school/fj/20240106/8e0d645d32b243ed865621a09d38fdc2%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240106105749.png',
  'https://szhy.artcollegehb.cn/school/file/school/fj/20240106/6e3cf8886386405085ec0bcabb5603c672ef236971180afef814f837d5476cd.png'
]);


// 轮播图点击处理
const handleBannerClick = (item: BannerItem) => {
  if (item.link) {
    uni.navigateTo({ url: item.link });
  } else if (item.type) {
    handleNavigate(item.type);
  }
};

const handleNavigate = (type: string) => {
  switch (type) {
    case 'ticket':
      uni.navigateTo({ url: '/pages/subscribe/subscribeDetails' });
      break;
    case 'programme':
      uni.navigateTo({ url: '/pages/programme/index' });
      break;
    case 'guide':
    uni.navigateTo({
        url: '/pages/tourGuide/index'
      });
      break;
    case 'scenic-hotel':
      uni.navigateTo({
        url: '/pages/tourGuide/index?type=hotel'
      });
      break;
    case 'service':
      uni.navigateTo({
        url: '/pages/tourGuide/index?type=service'
      });
      break;
    case 'food':
      uni.navigateTo({
        url: '/pages/tourGuide/index?type=food'
      });
      break;
    case 'movie-hotel':
      uni.navigateTo({
        url: '/pages/tourGuide/index?type=hotel-movie'
      });
      break;
  }
};

const handleCall = () => {
  uni.makePhoneCall({
    phoneNumber: '400-000-1992',
    success: () => {
      console.log('拨打电话成功');
    },
    fail: () => {
      uni.showToast({
        title: '拨打电话失败',
        icon: 'none'
      });
    }
  });
};
</script>

<style lang="scss">
.page-container {
  padding: 0 0 40rpx 0;
  background: linear-gradient(180deg, #F6F7F9 0%, #FFFFFF 100%);
  min-height: 100vh;
}

.swiper-section {
  position: relative;
  margin: 30rpx;
  border-radius: 36rpx;
  overflow: hidden;
  box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.06);

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.3) 100%);
    z-index: 1;
    pointer-events: none;
  }
}

.swiper-decoration {
  position: absolute;
  right: 40rpx;
  bottom: 40rpx;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12rpx;

  .decoration-line {
    width: 40rpx;
    height: 4rpx;
    background: #ffffff;
    border-radius: 4rpx;
  }

  .decoration-dot {
    width: 8rpx;
    height: 8rpx;
    background: #ffffff;
    border-radius: 50%;
  }
}

.grid-container {
  padding: 0 30rpx;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24rpx;
}

.grid-item {
  position: relative;
  overflow: hidden;
  border-radius: 36rpx;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2rpx solid rgba(255, 255, 255, 0.8);

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 100%);
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .item-content {
    position: relative;
    z-index: 2;
    padding: 36rpx 32rpx;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 280rpx;
  }

  .control-icon {
    font-size: 52rpx;
    margin-bottom: 24rpx;
    transition: transform 0.3s ease;
  }

  .text-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    .title {
      font-size: 32rpx;
      font-weight: 700;
      margin-bottom: 8rpx;
      display: block;
      letter-spacing: 0.5rpx;
      transition: transform 0.3s ease;
    }

    .subtitle {
      font-size: 22rpx;
      display: block;
      letter-spacing: 1rpx;
      text-transform: uppercase;
      transition: opacity 0.3s ease;
    }
  }

  .action, .book-now, .phone {
    margin-top: 20rpx;
    font-size: 24rpx;
    padding: 12rpx 28rpx;
    border-radius: 30rpx;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    letter-spacing: 0.5rpx;
    transition: all 0.3s ease;
    box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
  }
}

// 现代化配色方案
.ticket {
  background: linear-gradient(135deg, #FFEBEE 0%, #FFFFFF 100%);
  .control-icon, .title { color: #FF4757; }
  .subtitle { color: rgba(255, 71, 87, 0.7); }
  .action {
    background: rgba(255, 71, 87, 0.1);
    color: #FF4757;
    &:active {
      background: rgba(255, 71, 87, 0.2);
    }
  }
}

.programme {
  background: linear-gradient(135deg, #E3F2FD 0%, #FFFFFF 100%);
  .control-icon, .title { color: #5352ED; }
  .subtitle { color: rgba(83, 82, 237, 0.7); }
  .action {
    background: rgba(83, 82, 237, 0.1);
    color: #5352ED;
    &:active {
      background: rgba(83, 82, 237, 0.2);
    }
  }
}

.map {
  background: linear-gradient(135deg, #E3F2FD 0%, #FFFFFF 100%);
  .control-icon, .title { color: #2E86DE; }
  .subtitle { color: rgba(46, 134, 222, 0.7); }
  .action {
    background: rgba(46, 134, 222, 0.1);
    color: #2E86DE;
    &:active {
      background: rgba(46, 134, 222, 0.2);
    }
  }
}

.hotel {
  background: linear-gradient(135deg, #F1F8E9 0%, #FFFFFF 100%);
  .control-icon, .title { color: #4CAF50; }
  .subtitle { color: rgba(76, 175, 80, 0.7); }
  .action, .book-now {
    background: rgba(76, 175, 80, 0.1);
    color: #4CAF50;
    &:active {
      background: rgba(76, 175, 80, 0.2);
    }
  }
}

.service {
  background: linear-gradient(135deg, #FFFDE7 0%, #FFFFFF 100%);
  .control-icon, .title { color: #F1C40F; }
  .subtitle { color: rgba(241, 196, 15, 0.7); }
  .phone {
    background: rgba(241, 196, 15, 0.1);
    color: #F1C40F;
    &:active {
      background: rgba(241, 196, 15, 0.2);
    }
  }
}

.shop {
  background: linear-gradient(135deg, #E8F5E9 0%, #FFFFFF 100%);
  .control-icon, .title { color: #2196F3; }
  .subtitle { color: rgba(33, 150, 243, 0.7); }
  .action {
    background: rgba(33, 150, 243, 0.1);
    color: #2196F3;
    &:active {
      background: rgba(33, 150, 243, 0.2);
    }
  }
}

.movie {
  background: linear-gradient(135deg, #FFF8E1 0%, #FFFFFF 100%);
  .control-icon, .title { color: #FF9800; }
  .subtitle { color: rgba(255, 152, 0, 0.7); }
  .action {
    background: rgba(255, 152, 0, 0.1);
    color: #FF9800;
    &:active {
      background: rgba(255, 152, 0, 0.2);
    }
  }
}

.hotel-movie {
  background: linear-gradient(135deg, #FFF3E0 0%, #FFFFFF 100%);
  .control-icon, .title { color: #673AB7; }
  .subtitle { color: rgba(103, 58, 183, 0.7); }
  .action {
    background: rgba(103, 58, 183, 0.1);
    color: #673AB7;
    &:active {
      background: rgba(103, 58, 183, 0.2);
    }
  }
}

// 悬浮和点击效果
.grid-item {
  &:active {
    transform: scale(0.97);
    box-shadow: 0 5rpx 15rpx rgba(0, 0, 0, 0.03);

    .control-icon {
      transform: scale(0.95);
    }

    .title {
      transform: translateY(-2rpx);
    }

    .subtitle {
      opacity: 0.9;
    }

    .action {
      transform: translateY(2rpx);
    }
  }

  &:hover {
    &::before {
      opacity: 1;
    }
  }
}

// 暗色模式
@media (prefers-color-scheme: dark) {
  .page-container {
    background: linear-gradient(180deg, #1A1B1E 0%, #121214 100%);
  }

  .grid-item {
    background: rgba(45, 45, 48, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.2);

    &::before {
      background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
    }

    .subtitle {
      color: rgba(255, 255, 255, 0.6);
    }

    .action {
      background: rgba(255, 255, 255, 0.1);
      color: #FFFFFF;
    }
  }

  .swiper-section {
    box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.15);

    &::before {
      background: linear-gradient(180deg, rgba(0, 0, 0, 0.1) 70%, rgba(0, 0, 0, 0.4) 100%);
    }
  }

  .swiper-container {
    .swiper-image {
      opacity: 0.9;
    }
  }
}
</style>
